package com.ssy.lingxi.settle.accounts.entity;

import com.fasterxml.jackson.annotation.JsonManagedReference;

import javax.persistence.*;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

/**
 * 结算订单DO-待对账列表数据来源
 * @author Saske
 * @date 2021/12/14
 * @version 2.0.0
 */
@Entity
@Table(schema = "public",name = "sa_settlement_order",
        indexes = {@Index(name = "sa_settlement_order_billNo_idx",columnList = "billNo"),
                @Index(name = "sa_settlement_order_deliveryNo_idx",columnList = "deliveryNo"),
                @Index(name = "sa_settlement_order_receiveNo_idx",columnList = "receiveNo"),
                @Index(name = "sa_settlement_order_vendorMemberId_idx",columnList = "vendorMemberId"),
                @Index(name = "sa_settlement_order_vendorRoleId_idx",columnList = "vendorRoleId"),
                @Index(name = "sa_settlement_order_receiveTime_idx",columnList = "receiveTime"),
                @Index(name = "sa_settlement_order_payer_idx",columnList = "payer")
        })
public class SettlementOrderDO implements Serializable {

    private static final long serialVersionUID = -15024681655248741L;

    /**
     * ID
     */
    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "settlement_order_seq")
    @SequenceGenerator(sequenceName = "sa_settlement_order_seq", name = "settlement_order_seq", allocationSize = 1)
    private Long id;

    /**
     * 单据id，可以是订单id，或者售后id
     */
    @Column(name = "billId")
    private Long billId;

    /**
     * 单据编号，可以是订单编号，或者售后编号
     */
    @Column(name = "billNo",columnDefinition = "varchar(50)")
    private String billNo;

    /**
     * 买方（采购）会员Id
     */
    @Column(name = "buyerMemberId")
    private Long buyerMemberId;

    /**
     * 买方（采购）会员角色Id
     */
    @Column(name = "buyerRoleId")
    private Long buyerRoleId;

    /**
     * 卖方（供应）会员Id
     */
    @Column(name = "vendorMemberId")
    private Long vendorMemberId;

    /**
     * 卖方（供应）会员角色Id
     */
    @Column(name = "vendorRoleId")
    private Long vendorRoleId;

    /**
     * 收款方
     */
    @Column(name = "payee")
    private String payee;

    /**
     * 付款方
     */
    @Column(name = "payer")
    private String payer;

    /**
     * 发货批次
     */
    @Column(name = "deliveryBatch")
    private Integer deliveryBatch;

    /**
     * 发货单号
     */
    @Column(name = "deliveryNo")
    private String deliveryNo;

    /**
     * 发货时间
     */
    @Column(name = "deliveryTime")
    private LocalDateTime deliveryTime;

    /**
     * 收货单号
     */
    @Column(name = "receiveNo")
    private String receiveNo;

    /**
     * 收货时间
     */
    @Column(name = "receiveTime")
    private LocalDateTime receiveTime;

    /**
     * 订单状态
     */
    @Column(name = "orderStatus")
    private String orderStatus;

    /**
     * 订单类型
     */
    @Column(name = "orderType")
    private Integer orderType;

    /**
     * 单据类型
     * 定义： ApplyAmountRowBillTypeEnum
     */
    @Column(name = "billType")
    private Integer billType;

    /**
     * 单据总额
     */
    @Column
    private BigDecimal billAmount;
    /**
     * 单据日期
     */
    @Column
    private LocalDateTime billDate;

    /**
     * 单据摘要
     */
    @Column
    private String billAbstract;

    /**
     * 来源合同id, 0表示不存在
     */
    @Column
    private Long sourceContractId;

    /**
     * 一对多双向关联结算商品明细
     */
    @JsonManagedReference
    @OneToMany(mappedBy = "order", cascade = {CascadeType.PERSIST, CascadeType.REMOVE}, fetch = FetchType.LAZY)
    private List<SettlementProductDO> products;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Long getBillId() {
        return billId;
    }

    public void setBillId(Long billId) {
        this.billId = billId;
    }

    public String getBillNo() {
        return billNo;
    }

    public void setBillNo(String billNo) {
        this.billNo = billNo;
    }

    public Long getBuyerMemberId() {
        return buyerMemberId;
    }

    public void setBuyerMemberId(Long buyerMemberId) {
        this.buyerMemberId = buyerMemberId;
    }

    public Long getBuyerRoleId() {
        return buyerRoleId;
    }

    public void setBuyerRoleId(Long buyerRoleId) {
        this.buyerRoleId = buyerRoleId;
    }

    public Long getVendorMemberId() {
        return vendorMemberId;
    }

    public void setVendorMemberId(Long vendorMemberId) {
        this.vendorMemberId = vendorMemberId;
    }

    public Long getVendorRoleId() {
        return vendorRoleId;
    }

    public void setVendorRoleId(Long vendorRoleId) {
        this.vendorRoleId = vendorRoleId;
    }

    public String getPayee() {
        return payee;
    }

    public void setPayee(String payee) {
        this.payee = payee;
    }

    public String getPayer() {
        return payer;
    }

    public void setPayer(String payer) {
        this.payer = payer;
    }

    public Integer getDeliveryBatch() {
        return deliveryBatch;
    }

    public void setDeliveryBatch(Integer deliveryBatch) {
        this.deliveryBatch = deliveryBatch;
    }

    public String getDeliveryNo() {
        return deliveryNo;
    }

    public void setDeliveryNo(String deliveryNo) {
        this.deliveryNo = deliveryNo;
    }

    public String getReceiveNo() {
        return receiveNo;
    }

    public void setReceiveNo(String receiveNo) {
        this.receiveNo = receiveNo;
    }

    public LocalDateTime getDeliveryTime() {
        return deliveryTime;
    }

    public void setDeliveryTime(LocalDateTime deliveryTime) {
        this.deliveryTime = deliveryTime;
    }

    public LocalDateTime getReceiveTime() {
        return receiveTime;
    }

    public void setReceiveTime(LocalDateTime receiveTime) {
        this.receiveTime = receiveTime;
    }

    public String getOrderStatus() {
        return orderStatus;
    }

    public void setOrderStatus(String orderStatus) {
        this.orderStatus = orderStatus;
    }

    public Integer getOrderType() {
        return orderType;
    }

    public void setOrderType(Integer orderType) {
        this.orderType = orderType;
    }

    public Integer getBillType() {
        return billType;
    }

    public void setBillType(Integer billType) {
        this.billType = billType;
    }

    public List<SettlementProductDO> getProducts() {
        return products;
    }

    public void setProducts(List<SettlementProductDO> products) {
        this.products = products;
    }

    public BigDecimal getBillAmount() {
        return billAmount;
    }

    public void setBillAmount(BigDecimal billAmount) {
        this.billAmount = billAmount;
    }

    public LocalDateTime getBillDate() {
        return billDate;
    }

    public void setBillDate(LocalDateTime billDate) {
        this.billDate = billDate;
    }

    public String getBillAbstract() {
        return billAbstract;
    }

    public void setBillAbstract(String billAbstract) {
        this.billAbstract = billAbstract;
    }

    public Long getSourceContractId() {
        return sourceContractId;
    }

    public void setSourceContractId(Long sourceContractId) {
        this.sourceContractId = sourceContractId;
    }
}
